from dao import dataDao
from util import spider
from entire.dataDir import dataDir


def getDataList():
    data = dataDir()
    data.delete()
    num = 0
    Headlines = dataDao.searchHeadline()
    for index1, var1 in enumerate(Headlines):
        contents = dataDao.searchContentById(var1.headline_id)
        for index2, var2 in enumerate(contents):
            num += 1
            data.insert(num, var2.content_name, var1.headline_name, var2.content_url)
    return data.getList()


def spiderData():
    spider.spiderData()
    return 'OK'


def deleteData():
    dataDao.deleteAllData()
    return 'OK'
